home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / Projects / Questions & Answers / Q&A Programming Music / Programming random fractals < prev    next >
Lisp/Scheme  |  1998-10-26  |  3KB  |  114 lines

  1. MAKING RANDOM FRACTALS
  2.  
  3. (def-orchestra 'orchestra
  4.    all-instruments (synths)
  5.    synths (synth1 synth2 synth3 synth4 bass)
  6.    synth3 (synth3.mel synth3.cnt)
  7. )
  8.  
  9. (defun make-random-fractal (seed)
  10.   (let (out)
  11.     (init-rnd seed)
  12.     (initdef 'mel1)
  13.     (while (< (length out) 8)
  14.       (put (pack-name 'rules 'mel1)
  15.            'a 
  16.            (list (gen-random nil 4 '(a b c d))
  17.                  nil))
  18.       (put (pack-name 'rules 'mel1)
  19.            'b 
  20.            (list (gen-random nil 4 '(a b c d))
  21.                  nil))
  22.       (put (pack-name 'rules 'mel1)
  23.            'c 
  24.            (list (gen-random nil 4 '(a b c d))
  25.                  nil))
  26.       (setq out (gen-trans b 3 'mel1)))
  27.     out))
  28.  
  29. (setq seed 0.943323435344)
  30.  
  31. (make-random-fractal seed)
  32.  
  33. (def-section-timesheet sect-a
  34.    ;
  35.    ; timesheet
  36.    ;
  37.    with 1/1
  38.    ;          !---!---!---!---!---!---!---!---!
  39.    tonality  "            . . . . . . . . . " 
  40.              (fold-tonality 
  41.               'd 4 
  42.               (symbols-to-tonality
  43.                symbols (symbol-trim 8 (gen-trans a 4 'mel1))
  44.                transpose '((0 2 3 4))
  45.                mapping (symbols-to-tonality
  46.                         symbols (symbol-trim 4 (gen-trans b 4 'mel1))
  47.                         transpose '((0 2 3 4))
  48.                         mapping (activate-tonality (harmonic-minor c 3)))))
  49.    ;          +---!---+---!---+---!---+---!---+
  50.    synth3    "----------------------------  "
  51.    synth1    "    ----------------          "
  52.    bass      "        ----------------      "
  53.    synth2    "            ------------      "
  54.    synth4    "                    ----------"
  55. )
  56.  
  57.  
  58. (def-section sect-a
  59.   default
  60.     velocity '(70 54 54 64)
  61.   synth1
  62.     channel 2
  63.     length '(1/16 1/16 1/16 -1/16 -1/8 -1/8 -1/8 -1/8 -1/8 -1/8)
  64.     velocity '(70 54 54)
  65.     symbol '(acd)
  66.  bass
  67.     channel 4
  68.     length '(-1/16 -1/4.. 1/16 1/4..)
  69.     symbol (append (symbol-trim 2 (gen-trans a 4 'mel1))
  70.                    (symbol-trim 2 (gen-trans a 4 'mel1))
  71.                    (symbol-trim 2 (gen-trans a 4 'mel1))
  72.                    (symbol-trim 1 (gen-trans a 4 'mel1))
  73.                    (symbol-inversion 'd (symbol-trim 1 (gen-trans a 4 'mel1))))
  74.   synth2
  75.     channel 3
  76.     length '(-1/8 1/8 1/8 1/8 1/8 1/8 1/8 -1/8)
  77.     symbol (append (symbol-trim 4 (gen-trans a 4 'mel1))
  78.                    (symbol-trim 2 (gen-trans b 4 'mel1))
  79.                    
  80.                    
  81.                    )
  82.   synth4
  83.     channel 6
  84.     length '(1/32)
  85.     symbol (append (symbol-trim 8 (gen-trans a 4 'mel1))
  86.                    (symbol-trim 8 (gen-trans a 4 'mel1))
  87.                    (symbol-trim 8 (gen-trans a 4 'mel1))
  88.                    (symbol-trim 4 (gen-trans a 4 'mel1))
  89.                    (symbol-inversion 'd (symbol-trim 4 (gen-trans a 4 'mel1))))
  90.   synth3
  91.     channel 5
  92.     length '(1/16)
  93.     symbol (append (symbol-trim 8 (gen-trans a 4 'mel1))
  94.                    (symbol-trim 8 (gen-trans a 4 'mel1))
  95.                    (symbol-trim 8 (gen-trans a 4 'mel1))
  96.                    (symbol-trim 4 (gen-trans a 4 'mel1))
  97.                    (symbol-inversion 'd (symbol-trim 4 (gen-trans a 4 'mel1))))
  98.    synth3.cnt
  99.       symbol '(=)
  100.       velocity '(0)
  101.       length '(1/32) 
  102.       controller (mu80-controllers
  103.                    filter (fit-to-sheet (vector-round (center -10) (center 10) (gen-sin 1 1 256)))
  104.                  )
  105. )
  106.  
  107. ; you have to change controllers above, or remove the controllers 
  108.  
  109. (def-tempo 80)
  110.  
  111. (play-file-p nil
  112.    all-instruments '(sect-a)
  113. )
  114.